// This do-file extracts data on inflation from the IMF IFS

import delimited "$project_path/data/1_input/outcomes/imf/IFS_timeSeries.csv", encoding(UTF-8) clear

keep if indicatorname=="Prices, Consumer Price Index, All items, Percentage change, Corresponding period previous year, Percent" 

local i = 1920
foreach v of varlist v6-v106 {
	ren `v' inflation_imf`i'
	destring inflation_imf`i', replace
	local i = `i'+1
}

ren countryname Country
keep Country inflation_imf*
reshape long inflation_imf, i(Country) j(Year)

drop if inflation_imf==. | inflation_imf==0

replace Country="Afghanistan"  if Country=="Afghanistan, Islamic Rep. of"
replace Country="Armenia"  if Country=="Armenia, Rep. of"
replace Country="Aruba"  if Country=="Aruba, Kingdom of the Netherlands"
replace Country="Azerbaijan"  if Country=="Azerbaijan, Rep. of"
replace Country="Bahamas"  if Country=="Bahamas, The"
replace Country="Bahrain"  if Country=="Bahrain, Kingdom of"
replace Country="Belarus"  if Country=="Belarus, Rep. of"
replace Country="Bosnia-Herz"  if Country=="Bosnia and Herzegovina"
replace Country="Brunei"  if Country=="Brunei Darussalam"
replace Country="C. Verde Is."  if Country=="Cabo Verde"
replace Country="Cent. Af. Rep."  if Country=="Central African Rep."
replace Country="PRC"  if Country=="China, P.R.: Mainland"
replace Country="Comoro Is."  if Country=="Comoros, Union of the"
replace Country="Congo (DRC)"  if Country=="Congo, Dem. Rep. of the"
replace Country="Congo"  if Country=="Congo, Rep. of"
replace Country="Croatia"  if Country=="Croatia, Rep. of"
replace Country="Curacao"  if Country=="Curaçao, Kingdom of the Netherlands"
replace Country="Ivory Coast"  if Country=="Côte d'Ivoire"
replace Country="Dom. Rep."  if Country=="Dominican Rep."
replace Country="Egypt"  if Country=="Egypt, Arab Rep. of"
replace Country="Eq. Guinea"  if Country=="Equatorial Guinea, Rep. of"
replace Country="Estonia"  if Country=="Estonia, Rep. of"
replace Country="Swaziland"  if Country=="Eswatini, Kingdom of"
replace Country="Ethiopia"  if Country=="Ethiopia, The Federal Dem. Rep. of"
replace Country="Fiji"  if Country=="Fiji, Rep. of"
replace Country="Gambia"  if Country=="Gambia, The"
replace Country="FRG/Germany"  if Country=="Germany"
replace Country="Iran"  if Country=="Iran, Islamic Rep. of"
replace Country="Kazakhstan"  if Country=="Kazakhstan, Rep. of"
replace Country="Korea, Republic of"  if Country=="Korea, Rep. of"
replace Country="Kosovo"  if Country=="Kosovo, Rep. of"
replace Country="Kyrgyzstan"  if Country=="Kyrgyz Rep."
replace Country="Laos"  if Country=="Lao People's Dem. Rep."
replace Country="Lesotho"  if Country=="Lesotho, Kingdom of"
replace Country="Madagascar"  if Country=="Madagascar, Rep. of"
replace Country="Mauritania"  if Country=="Mauritania, Islamic Rep. of"
replace Country="Moldova"  if Country=="Moldova, Rep. of"
replace Country="Mozambique"  if Country=="Mozambique, Rep. of"
replace Country="Nauru"  if Country=="Nauru, Rep. of"
replace Country="Netherlands"  if Country=="Netherlands, The"
replace Country="Macedonia"  if Country=="North Macedonia, Republic of"
replace Country="Palau"  if Country=="Palau, Rep. of"
replace Country="P. N. Guinea"  if Country=="Papua New Guinea"
replace Country="Poland"  if Country=="Poland, Rep. of"
replace Country="Russia"  if Country=="Russian Federation"
replace Country="San Marino"  if Country=="San Marino, Rep. of"
replace Country="Serbia"  if Country=="Serbia, Rep. of"
replace Country="Sint Maarten"  if Country=="Sint Maarten, Kingdom of the Netherlands"
replace Country="Slovakia"  if Country=="Slovak Rep."
replace Country="Slovenia"  if Country=="Slovenia, Rep. of"
replace Country="Solomon Is."  if Country=="Solomon Islands"
replace Country="S. Africa"  if Country=="South Africa"
replace Country="South Sudan"  if Country=="South Sudan, Rep. of"
replace Country="Saint Kitts and Nevis"  if Country=="St. Kitts and Nevis"
replace Country="Saint Vincent and The Grenadines"  if Country=="St. Vincent and the Grenadines"
replace Country="Syria"  if Country=="Syrian Arab Rep."
replace Country="Sao Tome and Principe"  if Country=="São Tomé and Príncipe, Dem. Rep. of"
replace Country="Tajikistan"  if Country=="Tajikistan, Rep. of"
replace Country="Tanzania"  if Country=="Tanzania, United Rep. of"
replace Country="Timor-Leste"  if Country=="Timor-Leste, Dem. Rep. of"
replace Country="Trinidad-Tobago"  if Country=="Trinidad and Tobago"
replace Country="UAE"  if Country=="United Arab Emirates"
replace Country="UK"  if Country=="United Kingdom"
replace Country="USA"  if Country=="United States"
replace Country="Venezuela"  if Country=="Venezuela, Rep. Bolivariana de"
replace Country="Occupied Palestinian Territories"  if Country=="West Bank and Gaza"
replace Country="Yemen"  if Country=="Yemen, Rep. of"
drop if Country=="Advanced Economies"
drop if Country=="China, P.R.: Hong Kong"
drop if Country=="China, P.R.: Macao"
drop if Country=="Emerging and Developing Asia"
drop if Country=="Emerging and Developing Countries"
drop if Country=="New Caledonia"
drop if Country=="Sub-Saharan Africa"
drop if Country=="Western Hemisphere"
drop if Country=="World"

keep if Year>=1940
lab var inflation_imf "Inflation, consumer prices (annual %)"
notes inflation_imf : Source - IMF

save "$project_path/data/2_intermediary/outcomes/outcomes_imf.dta", replace
